
<!DOCTYPE html>

<html lang="zh_CN">
<head>
    <#include "../common/header.ftl"/>
    <script>
        $(function () {
            //修改推荐按钮绑定模态框
            $(".inputBtn").click(function () {
                //清空原来的值
                $("#editForm input").val("");
                //拿到json数据回显到模态框
                var json=$(this).data("json");
                if(json) {
                    $("#editForm input[name='id']").val(json.id);
                    $("#editForm input[name='name']").val(json.name);
                    $("#editForm input[name='sequence']").val(json.sequence);
                    $("#editForm select[name='state']").val(json.state.toString());
                    $("#editForm select[name='strategy.id']").val(json.strategyId);

                }
                //显示模态框
                $("#inputModal").modal("show");
            });
            //保存按钮绑定点击事件
            $(".btn-submit").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        reload();
                    }
                })
            });
        });
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#--设置作用于贡献数据，以回显菜单栏信息-->
            <#assign menu="strategyCatalog"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">攻略分类管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategyCatalog/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="strategyId" >所属攻略：</label>
                        <select id="strategyId" class="form-control" autocomplete="off" name="strategyId" >
                                <#list strategies as strategy>
                                    <option value="${strategy.id}">${strategy.title}</option>
                                </#list>
                        </select>
                </div>
                <#--回显高查下拉框的所属攻略-->
                <script>
                    $("#strategyId").val(${qo.strategyId!});
                </script>
                <button type="submit" class="form-control btn btn-primary">
                    <span class="glyphicon glyphicon-search">查询</span>
                </button>
                <button type="button" class="form-control btn btn-success inputBtn">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </button>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>分类名称</th>
                    <th>所属攻略</th>
                    <th>序列</th>
                    <th>状态</th>
                    <th></th>
                </tr>

                <#list pageInfo.list as entity>
                    <tr>
                       <td>${entity_index+1}</td>
                       <td>${entity.name}</td>
                       <td>${(entity.strategy.title)!}</td>
                       <td>${(entity.sequence)!}</td>
                       <td>${entity.state?string("启用","禁用")}</td>
                        <td>
                            <a class="inputBtn" data-json='${entity.json}' role="button">
                                <span class="glyphicon glyphicon-pencil"></span>修改</a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#--分页-->
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<#--推荐模态框-->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">攻略分类编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyCatalog/saveOrUpdate.do" method="post" id="editForm" enctype="multipart/form-data">
                    <input type="hidden" name="id">
                    <div class="form-group">
                        <label for="name" class="col-sm-4 control-label">分类名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name"
                                   placeholder="请输入分类名称">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">所属攻略：</label>
                        <div class="col-sm-6">
                            <select id="strategyId" class="form-control" autocomplete="off" name="strategy.id" >
                                <#list strategies as strategy>
                                    <option value="${strategy.id}">${strategy.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">序列号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select id="auditState" class="form-control" autocomplete="off" name="state" >
                                <option value="true">启用</option>
                                <option value="false">禁用</option>
                            </select>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
<style>
    /*给模态框中的图片设置样式*/
    #contentModal img{
        width: 100%;
    }
</style>
</html>